<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>无标题文档</title>
</head>
<script src="js/jquery-1.12.4.js"></script>
<body>
<form action="">
    <h1>病人信息</h1>
    <p>病人姓名* <input type="text"  value="${pt.name}"></p>
    <p>身份证号* <input type="text"  value="${pt.idCard}"></p>
    <p>家庭地址* <input type="text"  value="${pt.address}"></p>
    <p>性别* <input type="text" name="sex" value="${pt.sex==1?'男':'女'}"></p>
    <p>出生日期* <input type="text" ></p>
    <c:forEach items="${pt.registries}" var="p">
        <input type="hidden" value="${p.id}" id="rid">
        <input type="hidden" value="${p.sysUsers.id}" id="sid">

    <h1>添加医嘱</h1>
    <p>病人主诉* <textarea cols="50" rows="5" name="medicalAdvice.chiefComplaint" id="zs"></textarea></p>
    <p>诊断结果* <textarea cols="50" rows="5" name="medicalAdvice.diagnosis" id="di"></textarea></p>
    <input type="button" value="添加医嘱" onclick="add()"><br>
    <input type="button" value="诊断结束" onclick="location.href='reg!updateStatus?registry.id=${p.id}'">  <input type="button" value="返回">
    </c:forEach>
</form>
<script>
    function add(){

        var chiefComplaint=$("#zs").val();
        var diagnosis=$("#di").val();
        var rid=$("#rid").val();
        var sid=$("#sid").val();
        $.getJSON("med!queryByYz",{"medicalAdvice.registry.id":rid},function (json) {
                if(json==null||json==""||json==undefined){
                    location="med!addMed?medicalAdvice.registry.id="+rid+"&medicalAdvice.userId="+sid
                        +"&medicalAdvice.chiefComplaint="+chiefComplaint+"&medicalAdvice.diagnosis="+diagnosis;
                }else{
                   location="med!updateMed?medicalAdvice.chiefComplaint="
                       +chiefComplaint+"&medicalAdvice.diagnosis="+diagnosis+"&medicalAdvice.id="+json[0].id;
                }

        });
    }
</script>
</body>
</html>
